package com.entity;


import com.util.LocalInformation;

import java.util.ArrayList;

/**
 * Created by wlc on 2018/2/28.
 */
public class User {
    /**
     * 静态属性
     */
    private String id;
    private String username;
    private String password;
    private String realname;
    private String university;
    private String department;
    private String mail;
    private String permissions;
    private String login_time;
    /**
     * 动态属性
     */

    public User(){
        id = "null";
        username = "null";
        password = "null";
        realname = "null";
        university = "null";
        department = "null";
        mail = "null";
        permissions = "null";
        login_time = "null";
    }

    /**
     *数据成员设置和获取函数
     */
    public void setId(String id){
        this.id = id;
    }

    public String getId(){
        return id;
    }

    public void setUsername(String username){
        this.username = username;
    }

    public String getUsername() {
        return username;
    }

    public void setPassword(String password){
        this.password = password;
    }

    public String getPassword() {
        return password;
    }

    public void setRealname(String realname){
        this.realname = realname;
    }

    public String getRealname(){
        return realname;
    }

    public void setUniversity(String university){
        this.university = university;
    }

    public String getUniversity(){
        return university;
    }

    public void setDepartment(String department){
        this.department = department;
    }

    public String getDepartment(){
        return department;
    }

    public void setMail(String mail){
        this.mail = mail;
    }

    public String getMail(){
        return mail;
    }

    public void setPermissions(String permissions){
        this.permissions = permissions;
    }

    public String getPermissions(){
        return permissions;
    }

    public void setLogin_time(String login_time){
        this.login_time = login_time;
    }

    public String getLogin_time(){
        return login_time;
    }

    /**
     * 将用户信息存储到对象中
     * @param user_infor
     */
    public void readUserInfor(String user_infor){
        String[] temp_user_info = user_infor.split("wlcniubi");
        this.id = temp_user_info[0];
        this.username = temp_user_info[1];
        this.password = temp_user_info[2];
        this.realname = temp_user_info[3];
        this.university = temp_user_info[4];
        this.department = temp_user_info[5];
        this.mail = temp_user_info[6];
        this.permissions = temp_user_info[7];
        this.login_time = LocalInformation.getTimeID();
    }

    /**
     * 将用户信息转换为列表
     * @return ArrayList<String>
     */
    public ArrayList<String> userToList(){
        return new ArrayList<String>(){
            {
                add(id);
                add(username);
                add(password);
                add(realname);
                add(university);
                add(department);
                add(mail);
                add(permissions);
            }
        };
    }
}
